//
//  HomeSearchCell.m
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/8/30.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import "HomeSearchCell.h"
#import "SearchFirstTableViewCell.h"
#import "SearchListCell.h"
@interface HomeSearchCell ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *aTbView;
@end
@implementation HomeSearchCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        _aTbView = [[UITableView alloc] init];
        _aTbView.delegate = self;
        _aTbView.dataSource = self;
        _aTbView.scrollEnabled = NO;
        [self addSubview:_aTbView];
        [_aTbView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self);
            make.left.and.right.equalTo(self);
            make.height.greaterThanOrEqualTo(@(305));
        }];
        [_aTbView registerClass:[SearchFirstTableViewCell class] forCellReuseIdentifier:@"first"];
        [_aTbView registerClass:[SearchListCell class] forCellReuseIdentifier:@"cell"];
        _aTbView.separatorStyle = UITableViewCellSeparatorStyleNone;

        _aTbView.sectionFooterHeight = 54;
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, GWIDTH, 54)];
        view.backgroundColor = ColorWhite;
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, GWIDTH, 20)];
        label.textAlignment = 1;
        label.text = @"查看本店所有商品";
        label.textColor = ColorFrom16(0xF8C450);
        label.font = PFRFONT(14);
        [view addSubview:label];
        UIView *bg = [[UIView alloc] initWithFrame:CGRectMake(0, 44, GWIDTH, 10)];
        bg.backgroundColor = COLOR_BACKGROUND;
        [view addSubview:bg];
        
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 1, GWIDTH, 1)];
        line.backgroundColor = COLOR_BACKGROUND;
        [view addSubview:line];
        _aTbView.tableFooterView = view;
        
    }
    return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 0)
        return 113;
    else
        return 68;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 0)
    {
        SearchFirstTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"first"];
        return cell;
    }
    else
    {
        SearchListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        return cell;
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
